Page({
  data: {
    userInfo: {
      avatar: '',
      nickName: '',
    },
  },

  async getUserInfo() {
    const { code, data } = await wx.http.get('/userInfo')

    if (code !== 10000) return wx.utils.toast()

    this.setData({
      // userInfo: {
      //   avatar: data.avatar,
      //   nickName: data.nickName,
      // },
      userInfo: wx.utils.pick(data, ['avatar', 'nickName']),
    })
  },

  onShow() {
    this.getUserInfo()
  },
})
